package com.hanbang.gycatering.utils;

import com.hanbang.gangyu.R;

import android.content.Context;
import android.widget.Toast;

public class PagingHelp {

	// 总条数
	private int recordCount = -1;
	// 服务器数据的第几页
	private int pageindex = 1;
	// 上一次加载的第几条
	private int currentCount = 0;
	// 每页多少条
	private int pageCount = 20;

	public PagingHelp() {
		
	}

	public boolean isNextPaging(Context context, int result, int i) {
		if (currentCount == i) {
			// 没有跟多数据可以加载
			if (result != 0) {
				MyToast.show(context, context.getString(R.string.no_more_data),
						Toast.LENGTH_LONG);
				return false;
			}
		} else {
			currentCount = i;
			if (currentCount == pageCount) {
				// 如果加载满一页
				currentCount = 0;
				pageindex++;
			}
		}
		return true;
	}

	public void showNoData(Context context) {
		MyToast.show(context, context.getString(R.string.no_more_data),
				Toast.LENGTH_LONG);
	}

	/*
	 * 把数据清空 恢复到开始时的状态
	 */
	public void clear() {
		// 总条数
		recordCount = -1;
		// 服务器数据的第几页
		pageindex = 1;
		// 上一次加载的第几条
		currentCount = 0;
		// 每页多少条
		pageCount = 0;
	}

	public int getRecordCount() {
		return recordCount;
	}

	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}

	public int getPageindex() {
		return pageindex;
	}

	public void setPageindex(int pageindex) {
		this.pageindex = pageindex;
	}

	public int getCurrentCount() {
		return currentCount;
	}

	public void setCurrentCount(int currentCount) {
		this.currentCount = currentCount;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

}
